import Vue from 'vue'
// @ts-ignore
import App from './App.vue'
import store from './store'

// 引入路由器
import router from './router/index'

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

// 配置图片懒加载
import VueLazyload from 'vue-lazyload'
// @ts-ignore
import loading from './common/img/loading.gif'
Vue.use(VueLazyload, {
  loading
});
import animate from 'animate.css'
Vue.use(animate)
// 全局自定义指令
Vue.directive('move',
  {
    inserted: function (ele) {
      ele.onmousedown = function (e) { 
        var x = e.clientX - ele.offsetLeft
        var y = e.clientY - ele.offsetTop
        var MaxX = document.documentElement.clientWidth - ele.offsetWidth
        var MaxY = document.body.scrollHeight - ele.offsetHeight
        document.onmousemove = function (el) { 
          var Nowx = el.clientX - x
          var Nowy = el.clientY - y
          if (Nowx >= 0 && Nowx < MaxX) { 
            ele.style.left = Nowx + 'px'
          }
          if (Nowy >= 0 && Nowy <MaxY) { 
           ele.style.top=Nowy+'px'
          }
        }
        document.onmouseup = function () {
          document.onmousemove = null
          document.onmouseup = null
        }
      }
     }

  }
)

// 引入全局过滤器
import '@/config/filters'

import 'bootstrap/dist/css/bootstrap.css'

// i18n
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
import { messages } from './utils/i18n'
const i18n = new VueI18n({
  locale: 'zh',
  messages
})


new Vue({
  i18n,
  el:'#app',
  router,
  store,
  render: h=>h(App),
  beforeCreate(){
    Vue.prototype.$bus = this //安装全局事件总线
  }
});
